package com.ymatou.iapi.auth.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

/**
 * token认证Call FreeMaker Template自动生成代码
 */
public class SignAuthCall extends YmatouBaseCall {
	private static String opurl = "json/reply/SignAuthRequestDto";

	public SignAuthCall() {
		super(EnvSetup.getSystemUrl("auth_iapi"), opurl, "GET", "PARAM");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	/**
	 * 获取是否成功
	 * 
	 * @return Boolean
	 */
	public Boolean getSuccess() {
		Boolean Success = null;
		try {
			JSONObject jo = new JSONObject(getReturnData());
			Success = jo.getBoolean("Success");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Success;
	}

	/**
	 * 获取UserData
	 * 
	 * @return UserData
	 */
	public int getUserId() {
		int uid = 0;
		try {
			JSONObject jo = new JSONObject(getReturnData());
			uid = jo.getJSONObject("Result").getJSONObject("UserData").getInt("UserId");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return uid;
	}
}